/*
13. Write a program that exchanges bits 3, 4 and 5 with bits 24, 25 and 26 of given 32-bit unsigned integer.
*/
using System;

class modifieBitAtPosition
{
    static void Main()
    {
        Console.Write("Enter an integer: ");
        uint modifiedNumber = uint.Parse(Console.ReadLine());
        int mask;
        int modifiedNumberMask;
        int bitAtFirstPosition;
        int bitAtSecondPosition;
        int position = 3;
        while (position <= 5)
        {
            mask = 1 << position;
            modifiedNumberMask = (int)(modifiedNumber) & mask;
            bitAtFirstPosition = modifiedNumberMask >> position;
                
            mask = 1 << (position +21 );
            modifiedNumberMask = (int)(modifiedNumber) & mask;
            bitAtSecondPosition = modifiedNumberMask >> (position + 21);

            if (bitAtFirstPosition == 1)
            {
                mask = 1 << (position + 21);
                modifiedNumber |= (uint)(mask);
            }
            else
            {
                mask = ~(1 << (position + 21));
                modifiedNumber &= (uint)(mask);
            }

            if (bitAtSecondPosition == 1)
            {
                mask = 1 << position;
                modifiedNumber |= (uint)(mask);
            }
            else
            {
                mask = ~(1 << position);
                modifiedNumber &= (uint)(mask);
            }
            position++;
        } 
        Console.WriteLine("The modified number is {0}", modifiedNumber);
    }
}